package com.yzy.fly.domain;

import com.yzy.fly.api.function.response.entity.FlyBasicApiResponseEntity;
import lombok.Data;

import java.io.Serializable;

/**
 * @author xugj<br>
 * @version 1.0<br>
 * @createDate 2019/05/29 17:51 <br>
 * @Description <p> 返回响应数据 </p>
 */
@Data
public class RestMessage extends FlyBasicApiResponseEntity {

    protected String message;
    protected String code;
    protected Object data;
    protected Long costTime;
//
    public static RestMessage success(String message, Object data, long time){
        RestMessage restMessage = new RestMessage();
        restMessage.setCode("200");
        restMessage.setMessage(message);
        restMessage.setData(data);
        restMessage.setCostTime(time);
        return restMessage;
    }
//
    public static RestMessage fail(String message, Object data){
        RestMessage restMessage = new RestMessage();
        return fail(message,data, 0);
    }
//
    public static RestMessage fail(String message, Object data, long time){
        RestMessage restMessage = new RestMessage();
        restMessage.setCode("500");
        restMessage.setMessage(message);
        restMessage.setData(data);
        restMessage.setCostTime(time);
        return restMessage;
    }
}